package 剑指offer.斐波那契数列_7;

public class Main {
	public int Fibonacci(int n){
		int[] dp = new int[40];
		dp[0] = 0;
		dp[1] = 1;
		for(int i = 2; i <= n; i++){
			dp[i] = dp[i-1] + dp[i-2];
		}
		return dp[n];
	}
	
	public int Fibonacci2(int n){
		if(n == 1) return 1;
		int one = 0;
		int two = 1;
		int three = 0;
		for(int i = 2; i <= n; i++){
			three = one + two;
			one = two;
			two = three;
		}
		return three;
	}
}
